package com.ytktt.study.week3.task346.gateway.filter;

import com.ytktt.study.week3.task346.gateway.util.RequestUtil;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.FullHttpRequest;

import java.util.UUID;

public class HeaderHttpRequestFilter implements HttpRequestFilter {

    @Override
    public void filter(FullHttpRequest fullRequest, ChannelHandlerContext ctx) {
        fullRequest.headers().set("X-REAL-IP", RequestUtil.getIpAddress(fullRequest, ctx));
        fullRequest.headers().set("X-TRACE-ID", UUID.randomUUID().toString().replace("-", ""));
    }
}
